package Environment;

import java.awt.Color;

public class Environment {
	public Color tileColor;
	public String name = null;
	public int foodCount;
	public boolean isHabitable;
	public double connectionValue;
	public int similarCount;
	
	public int x;
	public int y;
	
	public Environment(int x_pos, int y_pos, Color newColor, String newName, int newFoodCount, boolean habitable, double connect)
	{
		tileColor = newColor;
		name = newName;
		foodCount = newFoodCount;
		isHabitable = habitable;
		connectionValue = connect;
		similarCount = 0;
		x=x_pos;
		y=y_pos;
	}
	
	public int FindSimilar(Environment[][] world)
	{
		for(int i=x-1; i<x+1; i++)
		{
			for(int j=y-1; j<y+1; j++)
			{
				if(i==x && j==y)
				{
					
				}
				else if(i>=world[0].length || j>=world.length )
				{
					
				}
				else if (i<0 || j<0)
				{
					
				}
				else
				{
					if(world[j][i].name.contains(name))
					{
						similarCount++;
					}
				}
			}
		}
		return similarCount;
	}
}
